VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{B3FB64BF-91F9-11D7-A482-0008A14158BC}#2.22#0"; "ITGControls.ocx"
Begin VB.Form frmSysStructure 
   BackColor       =   &H00F7D9C2&
   BorderStyle     =   0  'None
   Caption         =   "Form1"
   ClientHeight    =   6405
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   11340
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   6405
   ScaleWidth      =   11340
   ShowInTaskbar   =   0   'False
   Begin ITGControls.ComunionFrames fraSysStructure 
      Height          =   5835
      Left            =   0
      Top             =   15
      Width           =   10515
      _ExtentX        =   18547
      _ExtentY        =   10292
      FrameColor      =   16243138
      BackColor       =   16243138
      FillColor       =   16243138
      RoundedCorner   =   0   'False
      Caption         =   "Auto Numbering Setup"
      Alignment       =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      IconSize        =   32
      ThemeColor      =   5
      ColorFrom       =   16777215
      ColorTo         =   16243138
      Begin VB.ComboBox cboResetCtr 
         Appearance      =   0  'Flat
         Height          =   315
         Left            =   7215
         TabIndex        =   25
         Top             =   3705
         Width           =   1170
      End
      Begin VB.ComboBox cbommyear 
         Appearance      =   0  'Flat
         Height          =   315
         Left            =   7200
         TabIndex        =   22
         Top             =   2595
         Width           =   1200
      End
      Begin MSComctlLib.ListView lv 
         Height          =   4980
         Left            =   255
         TabIndex        =   20
         Top             =   660
         Width           =   4920
         _ExtentX        =   8678
         _ExtentY        =   8784
         View            =   3
         LabelEdit       =   1
         Sorted          =   -1  'True
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         FullRowSelect   =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         NumItems        =   2
         BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            Text            =   "Code"
            Object.Width           =   0
         EndProperty
         BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
            SubItemIndex    =   1
            Text            =   "Name"
            Object.Width           =   3528
         EndProperty
      End
      Begin VB.ListBox lst 
         Appearance      =   0  'Flat
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   3735
         Left            =   90
         TabIndex        =   0
         Top             =   5940
         Width           =   2445
      End
      Begin VB.Frame Frame1 
         BackColor       =   &H00F7D9C2&
         Caption         =   "Format Legend"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   915
         Left            =   5610
         TabIndex        =   11
         Top             =   4185
         Width           =   3435
         Begin VB.Label Label5 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "yy/yyyy - Year"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   1905
            TabIndex        =   15
            Top             =   570
            Width           =   1080
         End
         Begin VB.Label Label4 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "dd - Day"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   1920
            TabIndex        =   14
            Top             =   285
            Width           =   615
         End
         Begin VB.Label Label3 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "mm - Month"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   240
            TabIndex        =   13
            Top             =   570
            Width           =   840
         End
         Begin VB.Label Label2 
            AutoSize        =   -1  'True
            BackStyle       =   0  'Transparent
            Caption         =   "#/0 - Numerical"
            BeginProperty Font 
               Name            =   "Tahoma"
               Size            =   8.25
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   195
            Left            =   240
            TabIndex        =   12
            Top             =   300
            Width           =   1110
         End
      End
      Begin ITGControls.ITGTextBox txtFormatNo 
         Height          =   285
         Left            =   1125
         TabIndex        =   5
         TabStop         =   0   'False
         Top             =   5880
         Visible         =   0   'False
         Width           =   4005
         _ExtentX        =   6853
         _ExtentY        =   503
         BorderColor     =   16243138
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Label           =   "Numbering Format"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   2445
      End
      Begin ITGControls.ITGXPCheckBox cboTrans 
         Height          =   210
         Left            =   5685
         TabIndex        =   3
         Top             =   1515
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   370
         BackColor       =   16243138
         BorderColor     =   16243138
         ForeColor       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Transactional Module"
      End
      Begin ITGControls.ComunionButton cmdUp 
         Height          =   345
         Left            =   90
         TabIndex        =   1
         Top             =   9720
         Width           =   1215
         _ExtentX        =   2143
         _ExtentY        =   609
         BTYPE           =   14
         TX              =   "MoveUp"
         ENAB            =   -1  'True
         BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         COLTYPE         =   1
         FOCUSR          =   -1  'True
         BCOL            =   14215660
         BCOLO           =   14215660
         FCOL            =   0
         FCOLO           =   0
         MCOL            =   12632256
         MPTR            =   1
         MICON           =   "frmSysStructure.frx":0000
         UMCOL           =   -1  'True
         SOFT            =   0   'False
         PICPOS          =   0
         NGREY           =   0   'False
         FX              =   0
         HAND            =   0   'False
         CHECK           =   0   'False
         VALUE           =   0   'False
      End
      Begin ITGControls.ComunionButton cmdDown 
         Height          =   345
         Left            =   1320
         TabIndex        =   2
         Top             =   9720
         Width           =   1215
         _ExtentX        =   2143
         _ExtentY        =   609
         BTYPE           =   14
         TX              =   "MoveDown"
         ENAB            =   -1  'True
         BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         COLTYPE         =   1
         FOCUSR          =   -1  'True
         BCOL            =   14215660
         BCOLO           =   14215660
         FCOL            =   0
         FCOLO           =   0
         MCOL            =   12632256
         MPTR            =   1
         MICON           =   "frmSysStructure.frx":001C
         UMCOL           =   -1  'True
         SOFT            =   0   'False
         PICPOS          =   0
         NGREY           =   0   'False
         FX              =   0
         HAND            =   0   'False
         CHECK           =   0   'False
         VALUE           =   0   'False
      End
      Begin ITGControls.ITGXPCheckBox cboAutoNo 
         Height          =   210
         Left            =   5685
         TabIndex        =   4
         Top             =   1875
         Width           =   2055
         _ExtentX        =   3625
         _ExtentY        =   370
         BackColor       =   16243138
         BorderColor     =   16243138
         ForeColor       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Auto Numbering"
      End
      Begin ITGControls.ComunionButton cmdOK 
         Height          =   345
         Left            =   5685
         TabIndex        =   8
         Top             =   5265
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
         BTYPE           =   14
         TX              =   "O&k"
         ENAB            =   -1  'True
         BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         COLTYPE         =   1
         FOCUSR          =   -1  'True
         BCOL            =   15724527
         BCOLO           =   15724527
         FCOL            =   0
         FCOLO           =   0
         MCOL            =   12632256
         MPTR            =   1
         MICON           =   "frmSysStructure.frx":0038
         UMCOL           =   -1  'True
         SOFT            =   0   'False
         PICPOS          =   0
         NGREY           =   0   'False
         FX              =   0
         HAND            =   0   'False
         CHECK           =   0   'False
         VALUE           =   0   'False
      End
      Begin ITGControls.ComunionButton cmdCancel 
         Height          =   345
         Left            =   6795
         TabIndex        =   9
         Top             =   5265
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
         BTYPE           =   14
         TX              =   "&Cancel"
         ENAB            =   -1  'True
         BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         COLTYPE         =   1
         FOCUSR          =   -1  'True
         BCOL            =   15724527
         BCOLO           =   15724527
         FCOL            =   0
         FCOLO           =   0
         MCOL            =   12632256
         MPTR            =   1
         MICON           =   "frmSysStructure.frx":0054
         UMCOL           =   -1  'True
         SOFT            =   0   'False
         PICPOS          =   0
         NGREY           =   0   'False
         FX              =   0
         HAND            =   0   'False
         CHECK           =   0   'False
         VALUE           =   0   'False
      End
      Begin ITGControls.ComunionButton cmdApply 
         Height          =   345
         Left            =   7905
         TabIndex        =   10
         Top             =   5265
         Width           =   1095
         _ExtentX        =   1931
         _ExtentY        =   609
         BTYPE           =   14
         TX              =   "&Apply"
         ENAB            =   0   'False
         BeginProperty FONT {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         COLTYPE         =   1
         FOCUSR          =   -1  'True
         BCOL            =   15724527
         BCOLO           =   15724527
         FCOL            =   0
         FCOLO           =   0
         MCOL            =   12632256
         MPTR            =   1
         MICON           =   "frmSysStructure.frx":0070
         UMCOL           =   -1  'True
         SOFT            =   0   'False
         PICPOS          =   0
         NGREY           =   0   'False
         FX              =   0
         HAND            =   0   'False
         CHECK           =   0   'False
         VALUE           =   0   'False
      End
      Begin ITGControls.ITGTextBox txtAlphaVal 
         Height          =   285
         Left            =   5670
         TabIndex        =   6
         Top             =   2235
         Width           =   2715
         _ExtentX        =   4577
         _ExtentY        =   503
         BorderColor     =   16243138
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Label           =   "Alphabet Value"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1155
      End
      Begin ITGControls.ITGTextBox txtCounter 
         Height          =   285
         Left            =   8415
         TabIndex        =   7
         Top             =   3735
         Width           =   1560
         _ExtentX        =   2540
         _ExtentY        =   503
         BorderColor     =   16243138
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Text            =   "0"
         Label           =   "Counter"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         LabelWidth      =   700
         TextBoxWidth    =   800
      End
      Begin ITGControls.ITGXPCheckBox chkline 
         Height          =   210
         Left            =   8505
         TabIndex        =   16
         Top             =   2280
         Width           =   630
         _ExtentX        =   1111
         _ExtentY        =   370
         BackColor       =   16243138
         BorderColor     =   16243138
         ForeColor       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Line"
      End
      Begin ITGControls.ITGTextBox txtnumeric 
         Height          =   285
         Left            =   5685
         TabIndex        =   17
         Top             =   2970
         Width           =   2715
         _ExtentX        =   4577
         _ExtentY        =   503
         BorderColor     =   16243138
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Label           =   "Numerical"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   1155
      End
      Begin ITGControls.ITGTextBox txtformat 
         Height          =   285
         Left            =   5670
         TabIndex        =   18
         Top             =   3330
         Width           =   4290
         _ExtentX        =   7355
         _ExtentY        =   503
         BorderColor     =   16243138
         LabelBackColor  =   16243138
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Locked          =   -1  'True
         Label           =   "Numbering Format"
         BeginProperty LabelFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         TextBoxWidth    =   2730
      End
      Begin ITGControls.ITGXPCheckBox chkTransdate 
         Height          =   210
         Left            =   7875
         TabIndex        =   26
         Top             =   1875
         Width           =   2535
         _ExtentX        =   4471
         _ExtentY        =   370
         BackColor       =   16243138
         BorderColor     =   16243138
         ForeColor       =   0
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Caption         =   "Allow Editing Transaction Date"
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Reset Counter By"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Left            =   5715
         TabIndex        =   24
         Top             =   3735
         Width           =   1275
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "Month and Year"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   195
         Left            =   5670
         TabIndex        =   23
         Top             =   2670
         Width           =   1140
      End
      Begin VB.Label lblvalue 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         ForeColor       =   &H80000008&
         Height          =   315
         Left            =   5655
         TabIndex        =   21
         Top             =   1095
         Width           =   3390
      End
      Begin VB.Label lblAutoNumber 
         Appearance      =   0  'Flat
         BackColor       =   &H80000005&
         BackStyle       =   0  'Transparent
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9.75
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   315
         Left            =   5655
         TabIndex        =   19
         Top             =   705
         Width           =   3390
      End
   End
End
Attribute VB_Name = "frmSysStructure"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public rs As ADODB.Recordset
Public img As ImageList
Dim sID() As String
Dim nOrderID() As Integer
Dim nTransactional() As Integer
Dim nAutoNo() As Integer
Dim sFormat() As String
Dim sResetCtr() As String
Dim sAlphaVal() As String
Dim nCtr() As Integer
Dim sLine As String
Dim MonYear As String
Dim nIndex As Integer
Public sBit As String


'Security Acess Level variables
Public lACNew As Boolean
Public lACEdit As Boolean
Public lACDelete As Boolean
Public lACPost As Boolean
Public lACCancel As Boolean
Public lACPrint As Boolean

Public Sub LoadList()
Dim i As Integer
Dim sSpace As String
Dim n As Integer
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.Open "Select * from SYS_STRUCTURE", cn, adOpenKeyset

    If rs.RecordCount > 0 Then
        ReDim sID(0 To rs.RecordCount) As String
        ReDim nOrderID(0 To rs.RecordCount) As Integer
        ReDim nTransactional(0 To rs.RecordCount) As Integer
        ReDim nAutoNo(0 To rs.RecordCount) As Integer
        ReDim sFormat(0 To rs.RecordCount) As String
        ReDim sResetCtr(0 To rs.RecordCount) As String
        ReDim sAlphaVal(0 To rs.RecordCount) As String
        ReDim nCtr(0 To rs.RecordCount) As Integer
        ReDim nTransDate(0 To rs.RecordCount) As Integer 'add by denz:2/17/2011 for TransDate
        
        i = 0
        rs.MoveFirst
        lst.Clear
  
        Do Until rs.EOF
            sID(i) = rs!cCode
            nOrderID(i) = IIf(IsNull(rs!nOrderID), i, rs!nOrderID)
            nTransactional(i) = IIf(IsNull(rs!lTransactional), 0, rs!lTransactional)
            nAutoNo(i) = IIf(IsNull(rs!lAutoNo), 0, rs!lAutoNo)
            sFormat(i) = IIf(IsNull(rs!cNumberFormat), "", rs!cNumberFormat)
            sResetCtr(i) = IIf(IsNull(rs!cResetCtr), "", rs!cResetCtr)
            sAlphaVal(i) = IIf(IsNull(rs!cAlphaVal), "", rs!cAlphaVal)
            nCtr(i) = IIf(IsNull(rs!nCtr), "", rs!nCtr)
            sSpace = ""
            For n = 1 To rs!nLevel
                sSpace = sSpace & "     "
            Next n
            lst.AddItem sSpace & rs!cCaption
            nTransDate(i) = IIf(IsNull(rs!TransDate), 0, rs!TransDate)
            i = i + 1
            rs.MoveNext
        Loop
    End If
End Sub

Private Sub cbommyear_Change()
    FormatAutoNumber
End Sub

Private Sub cbommyear_Click()
    FormatAutoNumber
    txtnumeric.SetFocus
End Sub

Private Sub cbommyear_GotFocus()
    FormatAutoNumber
End Sub

Private Sub cbommyear_KeyPress(KeyAscii As Integer)
    KeyAscii = 0
End Sub

Private Sub cbommyear_LostFocus()
    FormatAutoNumber
End Sub

Private Sub cboResetCtr_Change()
On Error GoTo ErrHandler
    cmdApply.Enabled = True

ErrHandler:
    If err.Number <> 0 Then MsgBox err.Number & ":" & err.Description
End Sub

Private Sub cboResetCtr_Click()
On Error GoTo ErrHandler
    cmdApply.Enabled = True

ErrHandler:
    If err.Number <> 0 Then MsgBox err.Number & ":" & err.Description
End Sub

Private Sub chkline_Click()
If Trim(txtAlphaVal.Text) = "" Then
    If chkline.Value = 1 Then
        chkline.Value = 1
    Else: chkline.Value = 0
    End If
End If
FormatAutoNumber
End Sub

Private Sub cmdApply_Click()
On Error GoTo ErrHandler
    If cboAutoNo.Value = 1 Then
        If Trim(cbommyear.Text) = "" Then
            MsgBox "Field 'Month and Year' is mandatory. Null value is not allowed.", vbInformation, msgTtl
            cbommyear.SetFocus
            Exit Sub
        ElseIf Trim(txtnumeric) = "" Then
            MsgBox "Field 'Numeric' is mandatory. Null value is not allowed.", vbInformation, msgTtl
            txtnumeric.SetFocus
            Exit Sub
        ElseIf Trim(cboResetCtr.Text) = "" Then
            MsgBox "Field 'Reset Counter By' is mandatory. Null value is not allowed.", vbInformation, msgTtl
            cboResetCtr.SetFocus
            Exit Sub
        ElseIf Len(Trim(txtnumeric)) < 6 Then
            MsgBox "The Minimum length of numerical digit is six(6).", vbInformation, msgTtl
            txtnumeric.SetFocus
            SendKeys "{HOME} + {END}"
            Exit Sub
        ElseIf Len(Trim(txtFormat)) > 20 Then
            MsgBox "The Maximum length of Numbering Format is twenty(20).", vbInformation, msgTtl
            Exit Sub
        End If
    End If

    UpdateChange

ErrHandler:
If err.Number <> 0 Then MsgBox err.Number & ":" & err.Description
End Sub

Private Sub UpdateChange()
Dim i As Integer
Dim sql As String
On Error GoTo ErrHandler
sql = "UPDATE system_autonumber SET lTransactional=" & cboTrans.Value & _
        ", lAutoNo =" & cboAutoNo.Value & ", cNumberFormat= '" & txtFormat.Text & "',cResetCtr ='" & _
        cboResetCtr.Text & "', cAlphaVal ='" & txtAlphaVal.Text & "', nCtr = " & txtCounter.Text & _
        " , cAutoNumberLabel = '" & lblAutoNumber.Caption & "',  cValue = '" & lblvalue.Caption & _
        "' , cMMYYYY = '" & cbommyear.Text & "', lLine = " & chkline.Value & " ,  cNumeric = '" & txtnumeric.Text & _
        "' ,lTransDate = '" & chkTransdate.Value & "'  WHERE cCode = '" & lv.SelectedItem & "' AND cCompanyID = '" & COID & "' "
        cn.Execute sql
        MsgBox "Successfully Updated.", vbInformation, msgTtl

ErrHandler:
    If err.Number <> 0 Then MsgBox err.Description
End Sub

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub cmdOK_Click()
    If cmdApply.Enabled = True Then Call cmdApply_Click
    Call cmdCancel_Click
End Sub



Private Sub Form_Unload(Cancel As Integer)
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , True

    Set frmSysStructure = Nothing
    
    lCloseWindow = True
    CloseMenuTab ITGLedgerMain

End Sub

Private Sub Form_Load()
    Set FrmName = Me
    FormSetup
    
    AcessBit Me, GetValueFrTable("AccessLevel", "SEC_ACCESSLEVEL", "RoleID = '" & SecUserRole & "' AND [Module] = 'SS07'")

    
    BitEnabled ITGLedgerMain, Me, ITGLedgerMain.tbrMain, , , , , , , , , , , , , True
    
    cboResetCtr.AddItem "NONE"
    cboResetCtr.AddItem "DAILY"
    cboResetCtr.AddItem "MONTHLY"
    cboResetCtr.AddItem "ANNUALY"
    
    cbommyear.AddItem "NONE"
    cbommyear.AddItem "mmddyy"
    cbommyear.AddItem "mmyy"
    cbommyear.AddItem "mmyyyy"
    cbommyear.AddItem "yy"
    cbommyear.AddItem "yyyy"
    FillList
End Sub

Public Sub TBCloseWindow()
    Unload Me
End Sub

Public Sub TBBitReload()
    Set FrmName = Me
    BitVisible ITGLedgerMain.tbrMain, True, True
    sBit = "0000000000000000"
    BitReload ITGLedgerMain, Me, ITGLedgerMain.tbrMain, sBit
End Sub

Sub FillList()
    Set rs = Nothing
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open "SELECT cCode, cAutonumberLabel FROM system_autonumber where cCompanyID = '" & COID & "'", cn, adOpenKeyset
    If Not rs.EOF Then
        While Not rs.EOF
'            lv.ListItems.Add , , rs!cCode
'            lv.ListItems(lv.ListItems.Count).ListSubItems.Add , , rs!cAutoNumberLabel
'            lv.Refresh

            Set itmX = lv.ListItems.Add(, , rs!cCode & "")
                itmX.SubItems(1) = rs!cAutoNumberLabel & ""
        rs.MoveNext
        Wend
    End If
End Sub


Private Sub lv_ItemClick(ByVal Item As MSComctlLib.ListItem)
    Set rs = Nothing
    Set rs = New ADODB.Recordset
    rs.CursorLocation = adUseClient
    rs.Open "SELECT * FROM system_autonumber where cCompanyID = '" & COID & "' AND cCode = '" & lv.SelectedItem & "'", cn, adOpenKeyset, adLockPessimistic
        
    If Not rs.EOF Then
        lblAutoNumber.Caption = IIf(IsNull(rs!cAutoNumberLabel), "", rs!cAutoNumberLabel)
        lblvalue.Caption = IIf(IsNull(rs!cValue), "", rs!cValue)
        If (IsNull(rs!lTransactional) = True) Then
            cboTrans.Value = 0
        Else
            If rs!lTransactional = True Then
                cboTrans.Value = 1
            Else: cboTrans.Value = 0
            End If
        End If
        
        If (IsNull(rs!lAutoNo) = True) Then
            cboAutoNo.Value = 0
        Else
            If rs!lAutoNo = True Then
                cboAutoNo.Value = 1
            Else: cboAutoNo.Value = 0
            End If
        End If
        If (IsNull(rs!lLine) = True) Then
            chkline.Value = 0
        Else
            If rs!lLine = True Then
                chkline.Value = 1
            Else: chkline.Value = 0
            End If
        End If
        If (IsNull(rs!lTransDate) = True) Then 'add by denz:2/17/2011 for transdate
            chkTransdate.Value = 0
        Else
             If rs!lTransDate = True Then
                chkTransdate.Value = 1
            Else: chkTransdate.Value = 0
            End If
        End If
        
        txtAlphaVal.Text = IIf(IsNull(rs!cAlphaVal), "", rs!cAlphaVal)
        cbommyear.Text = IIf(IsNull(rs!cMMYYYY), "", rs!cMMYYYY)
        txtnumeric.Text = IIf(IsNull(rs!cNumeric), "", rs!cNumeric)
        cboResetCtr.Text = IIf(IsNull(rs!cResetCtr), "", rs!cResetCtr)
        txtCounter.Text = IIf(IsNull(rs!nCtr), "", rs!nCtr)
        txtFormat.Text = IIf(IsNull(rs!cNumberFormat), "", rs!cNumberFormat)
    End If
End Sub

Private Sub txtAlphaVal_Change()
    cmdApply.Enabled = True
    FormatAutoNumber
End Sub
Private Sub txtCounter_Change()
    cmdApply.Enabled = True
End Sub
Private Sub txtFormatNo_Change()
    cmdApply.Enabled = True
End Sub

Sub FormatAutoNumber()
    If chkline.Value = 1 Then
        If Trim(txtAlphaVal.Text) <> "" Then
            sLine = "-"
        End If
    Else: sLine = ""
    End If
    
    If cbommyear.Text = "NONE" Then
        MonYear = ""
    Else: MonYear = cbommyear.Text
    End If
     txtFormat.Text = txtAlphaVal.Text & sLine & MonYear & txtnumeric.Text
End Sub

Private Sub txtnumeric_Change()
FormatAutoNumber
End Sub

Private Sub txtnumeric_KeyPress(KeyAscii As Integer)
Dim str As String
Dim X As Integer
    str = "#0"
    X = InStr(1, str, Chr$(KeyAscii))
    If X = 0 And KeyAscii <> 8 Then
        KeyAscii = 0
    End If
End Sub
